<?php
if(isset($_REQUEST['onsub'])){
    if( $_REQUEST['onsub']=='ok')
    {
          //require_once dirname(__FILE__) . '/../includes/common.inc.php';
          require_once dirname(__FILE__) . '/../includes/data.cfg.php';
          require_once dirname(__FILE__) . '/../includes/pdoorm.inc.php';
        
          $export_name = BRANCH.'product';
          header("Content-type:application/vnd.ms-excel");
          header("Content-Disposition:attachment;filename=$export_name.xls");
        
        
          //require_once dirname(__FILE__) . '/includes/pdoorm.inc.php';
          
          
          $sql="SELECT name,price FROM ns_v1sample order by name";
          $dataarr = getall($sql,1);
          echo"<table border='1'><tr>";
          echo " <td colspan='2' height='30px' align='center'><h1>".$export_name."</h1></td></tr><tr height='27' style='font-weight:bold;'>";
          echo   "<td>product name</td>";
          echo   "<td>product price</td>";
          echo  "</tr>";  
        
          if(is_array($dataarr))
          {
            foreach ($dataarr as $dr)
            {
               echo" <tr>";        
               echo   "<td>".$dr['name']."</td>";
               echo   "<td>".$dr['price']."</td>";
               echo  "</tr>";      
            }
          }
          echo"</table>";
          die;
    }

}
//header("Content-type: text/html; charset=utf-8");

?>
 <br>
 <div>
    <fieldset>
    <legend>Product</legend>
      <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
        <label><input type="hidden" name="onsub" id="onsub"  value="ok">
        <input type="submit" value="download"></label>
      </form>
    </fieldset>
    </fieldset>
 </div>